import os
for base, dirs, files in os.walk('scripts'):
    print(base)
    print(dirs)
    print(files)
    for filename in files:
        filepath = os.path.join(base, filename)
        with open(filepath) as _file:
            size = _file.seek(0, os.SEEK_END)
            _file.seek(size - 1)
            last_char = _file.read(1)
        print(filename, repr(last_char))
        if last_char == '\n':
            continue
        with open(filepath, 'a') as _file:
            _file.write('\n')
